﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Lion.WeiXin.Core.Data
{
    /// <summary>
    /// 数据访问上下文
    /// </summary>
   public class DBContext
    {
       
       public DBContext()
       {
          
       }      

      /// <summary>
      /// 订单接口(实际调用时才实例化)
      /// </summary>
       public IOrder Orders {
           get { return new OrderDAO(); }
           set { }
       }
       /// <summary>
       /// 产品接口
       /// </summary>
       public IProduct Products
       {
           get { return new ProductDAO(); }
           set { }
       }
       /// <summary>
       /// 字典数据接口
       /// </summary>
       public IDictionary Dictionarys {
           get
           {
               IDictionary idic = null;
               return SetMockObject(idic);
           }
       }
       /// <summary>
       /// 模板数据接口
       /// </summary>
       public ITemplate Templates
       {
           get
           {
               ITemplate itemp = null;
               return SetMockObject(itemp);
           }
       }
       /// <summary>
       /// 文章分类接口
       /// </summary>
       public ICategory Categorys {
           get
           {
               ICategory itemp = null;
               return SetMockObject(itemp);
           }
       }

       public IArticle Articles {
           get
           {
               IArticle itemp = null;
               return SetMockObject(itemp);
           }
       }

       public INews News {
           get
           {
               INews itemp = null;
               return SetMockObject(itemp);
           }
       }

       public IVipCard VipCards
       {
           get
           {
               IVipCard itemp = null;
               return SetMockObject(itemp);
           }
       }

       public IAutoReply AutoReplys
       {
           get
           {
               IAutoReply itemp = null;
               return SetMockObject(itemp);
           }
       }

       public IWeChatUser WeChatUsers
       {
           get
           {
               IWeChatUser itemp = null;
               return SetMockObject(itemp);
           }
       }

       public IValidate Validates
       {
           get
           {
               IValidate itemp = null;
               return SetMockObject(itemp);
           }
       }

       public IVipCardUseLog VipCardUseLogs
       {
           get
           {
               IVipCardUseLog itemp = null;
               return SetMockObject(itemp);
           }
       }

       public IOperateLog Logs
       {
           get
           {
               IOperateLog itemp = null;
               return SetMockObject(itemp);
           }
       }

       public IEmployee Employees
       {
           get
           {
               IEmployee itemp = null;
               return SetMockObject(itemp);
           }
       }

       public ICmsMenu CmsMenus
       {
           get
           {
               ICmsMenu itemp = null;
               return SetMockObject(itemp);
           }
       }

       protected ICmsMenu SetMockObject(ICmsMenu mockInterface)
       {
           if (mockInterface == null)
           {
               return new CmsMenuDAO();
           }
           else
           {
               return mockInterface;
           }
       }

       protected IEmployee SetMockObject(IEmployee mockInterface)
       {
           if (mockInterface == null)
           {
               return new EmployeeDAO();
           }
           else
           {
               return mockInterface;
           }
       }

       protected IOperateLog SetMockObject(IOperateLog mockInterface)
       {
           if (mockInterface == null)
           {
               return new OperateLogDAO();
           }
           else
           {
               return mockInterface;
           }
       }

       protected IVipCardUseLog SetMockObject(IVipCardUseLog mockInterface)
       {
           if (mockInterface == null)
           {
               return new VipCardUseLogDAO();
           }
           else
           {
               return mockInterface;
           }
       }

       protected IValidate SetMockObject(IValidate mockInterface)
       {
           if (mockInterface == null)
           {
               return new ValidateDAO();
           }
           else
           {
               return mockInterface;
           }
       }

       protected IWeChatUser SetMockObject(IWeChatUser mockInterface)
       {
           if (mockInterface == null)
           {
               return new WeChatUserDAO();
           }
           else
           {
               return mockInterface;
           }
       }

       protected IAutoReply SetMockObject(IAutoReply mockInterface)
       {
           if (mockInterface == null)
           {
               return new AutoReplyDAO();
           }
           else
           {
               return mockInterface;
           }
       }

       protected IVipCard SetMockObject(IVipCard mockInterface)
       {
           if (mockInterface == null)
           {
               return new VipCardDAO();
           }
           else
           {
               return mockInterface;
           }
       }

       protected INews SetMockObject(INews mockInterface)
       {
           if (mockInterface == null)
           {
               return new NewsDAO();
           }
           else
           {
               return mockInterface;
           }
       }

       protected IArticle SetMockObject(IArticle mockInterface)
       {
           if (mockInterface == null)
           {
               return new ArticleDAO();
           }
           else
           {
               return mockInterface;
           }
       }

       protected ICategory SetMockObject(ICategory mockInterface)
       {
           if (mockInterface == null)
           {
               return new CategoryDAO();
           }
           else
           {
               return mockInterface;
           }
       }

       protected IDictionary SetMockObject(IDictionary mockInterface)
       {
           if (mockInterface == null)
           {
               return new DictionaryDAO();
           }
           else
           {
               return mockInterface;
           }
       }

     
       /// <summary>
       /// 该方法保障测试可以模拟接口
       /// </summary>
       /// <param name="mockInterface"></param>
       /// <returns></returns>
       protected ITemplate SetMockObject(ITemplate mockInterface)
       {
           if (mockInterface == null)
           {
               return new TemplateDAO();
           }
           else {
               return mockInterface;
           }
       }


    }
}
